//
//  JoinUsWantedDetailFooterCell.swift
//  甜言蜜语
//
//  Created by yingli_yanfa_liuxingyu on 16/7/31.
//  Copyright © 2016年 wl. All rights reserved.
//

import UIKit

class JoinUsWantedDetailFooterCell: UITableViewCell {
    @IBOutlet weak var tableView: UITableView!

    var modelList: [JoinUsModel]?
    
    override func awakeFromNib() {
        super.awakeFromNib()
        
        let cellNib = UINib(nibName: "JoinUsWantJobFooterDetailCell", bundle: nil)
        
        self.tableView.registerNib(cellNib, forCellReuseIdentifier: "JoinUsWantJobFooterDetailCell")
        
        self.tableView.scrollEnabled = false
        

    }

    override func setSelected(selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    func setCellContentWithCellInfo(cellInfo: [JoinUsModel]?) -> Void {
        
        self.modelList = cellInfo
        
        self.tableView.reloadData()
        
        
    }
    
    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        if modelList?.count == nil{
            return 0
        }else{
            return (modelList?.count)!
        }
              
    }
    func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
         return 118
        
        
    }
    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        
        let cell = tableView.dequeueReusableCellWithIdentifier("JoinUsWantJobFooterDetailCell", forIndexPath: indexPath) as! JoinUsWantJobFooterDetailCell
        let model = modelList![indexPath.row]
        
        cell.iv.sd_setImageWithURL(NSURL(string: (format: model.imgsrc)), placeholderImage: UIImage(named: "placeholder"))
        
        cell.titleLbl.text = String(format: "%@%@%@",model.type ,model.unittype , model.positiontype)
        cell.nameLbl.text = model.name
        cell.sexLbl.text = model.sex
        cell.ageLbl.text = model.age
        cell.liftLbl.text = model.lift
        cell.addressLbl.text = model.unitarea
        cell.payLbl.text = model.pay
        
        return cell
    }
    
    // MARK: - Table view delegate
    func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
            
        tableView.deselectRowAtIndexPath(indexPath, animated: true)
        
        let model = modelList![indexPath.row]
        
        let dic = ["id":model.id, "type":model.type]
    NSNotificationCenter.defaultCenter().postNotificationName("JoinUsWantJobDetail_Noti", object: dic)
    }
        
}
